<template>
  <el-container>
    <el-header>
      <el-menu mode="horizontal" router>
        <el-menu-item index="/">短链生成</el-menu-item>
        <el-menu-item index="/dashboard">数据统计</el-menu-item>
        <el-menu-item v-if="!token" index="/login">登录</el-menu-item>
        <el-menu-item v-else @click="handleLogout">登出</el-menu-item>
      </el-menu>
    </el-header>
    
    <el-main>
      <router-view></router-view>
    </el-main>

    <!-- 添加一些测试内容 -->
    <div style="text-align: center; margin: 20px;">
      {{ message }}
    </div>
  </el-container>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'

const router = useRouter()
const token = ref('')
const message = ref('测试内容 - 如果看到这个说明 Vue 已经正确加载')

onMounted(() => {
  token.value = localStorage.getItem('token')
  console.log('App mounted')  // 添加调试日志
})

const handleLogout = () => {
  localStorage.removeItem('token')
  token.value = ''
  ElMessage.success('已登出')
  router.push('/login')
}
</script>

<style>
.el-container {
  min-height: 100vh;
}

.el-header {
  padding: 0;
}

.el-main {
  padding: 20px;
}
</style> 